package com.yyfax.pay.third.facade.minsheng;

import com.yyfax.commons.json.JacksonUtil;
import com.yyfax.commons.lang.NumberUtil;
import com.yyfax.framework.model.Content;
import com.yyfax.framework.model.Params;
import com.yyfax.pay.common.enums.PayModeEnum;
import com.yyfax.pay.common.enums.PayRspCodeEnum;
import com.yyfax.pay.common.enums.PayTypeEnum;
import com.yyfax.pay.common.enums.PaymentEnum;
import com.yyfax.pay.common.exception.YYPayException;
import com.yyfax.pay.config.data.service.MerchantPaymentService;
import com.yyfax.pay.config.model.po.MerchantPaymentPO;
import com.yyfax.pay.third.facade.minsheng.util.MinshengUtil;
import com.yyfax.pay.third.model.to.minsheng.CheckBatchPayoutOrderMinshengContent;
import com.yyfax.pay.third.model.to.minsheng.CheckBatchPayoutOrderMinshengParams;
import com.yyfax.pay.third.model.to.minsheng.MinshengBatchPayVo;
import com.yyfax.pay.third.model.to.minsheng.MinshengExt;
import com.yyfax.pay.third.model.to.minsheng.PayoutOrderMinshengContent;
import com.yyfax.pay.third.model.to.minsheng.PayoutOrderMinshengParams;
import com.yyfax.pay.third.model.to.minsheng.QueryBatchPayoutOrderMinshengContent;
import com.yyfax.pay.third.model.to.minsheng.QueryBatchPayoutOrderMinshengParams;
import com.yyfax.pay.third.model.to.yyfax.*;
import com.yyfax.pay.third.model.to.yyfax.PayoutBatchOrderYYParams.PayoutOrderYY;
import com.yyfax.pay.third.service.TransformService;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author AlanQiu on 2017/4/18.
 */
@Service("minshengTransformService")
public class MinshengTransformService implements TransformService {

	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private MerchantPaymentService merchantPaymentService;

	@Override
	public <P extends Params> P transformQueryPayOrderParams(QueryPayOrderYYParams req) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> QueryPayOrderYYContent transformQueryPayOrderContent(C rsp) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformAuthenticationParams(AuthenticationYYParams req) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> AuthenticationYYContent transformAuthenticationContent(C rsp) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformBatchPayoutOrderCheckParams(QueryBatchPayoutOrderCheckYYParams req) throws Exception {

		MinshengExt minshengExt = getMerchantInfo(req.getMerchantCode());
		String date = req.getBatchDate();

		// 当天第几个批次
		String batchNo = req.getBatchNo();

		String keys = minshengExt.getKeys();
		byte[] keyBytes = MinshengUtil.hex2bin(keys);

		String dateTime = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");

		String commpName = minshengExt.getCommpName();
		String bindAcct = minshengExt.getBindAcct();
		String bindAcctName = minshengExt.getBindAcctName();

		// 构造报文体
		String body = String.format("%s|%s|%s|%s|%s|", commpName, date, batchNo, bindAcct, bindAcctName);
		byte[] bodyBytes = body.getBytes("UTF-8");
		byte[] toMD5 = new byte[38 + bodyBytes.length];
		System.arraycopy(keyBytes, 0, toMD5, 0, 24);
		System.arraycopy(dateTime.getBytes(), 0, toMD5, 24, 14);
		System.arraycopy(bodyBytes, 0, toMD5, 38, bodyBytes.length);

		String vis = minshengExt.getVis();
		String algorithm = minshengExt.getAlgorithm();
		String commpCode = minshengExt.getCommpCode();

		String bodyMD5 = MinshengUtil.getMD5(toMD5);
		bodyBytes = MinshengUtil.encrypt(bodyBytes, keys, vis, algorithm);

		String header = String.format("%08d%-12s100010%06d%-14s%-16s%32s", bodyBytes.length, "PA001B303", bodyBytes.length, dateTime, commpCode,
				bodyMD5);

		CheckBatchPayoutOrderMinshengParams checkBatchPayoutOrderMinshengParams = new CheckBatchPayoutOrderMinshengParams();
		checkBatchPayoutOrderMinshengParams.setHost(minshengExt.getHost());
		checkBatchPayoutOrderMinshengParams.setAlgorithm(algorithm);
		checkBatchPayoutOrderMinshengParams.setBody(body);
		checkBatchPayoutOrderMinshengParams.setHeader(header);
		checkBatchPayoutOrderMinshengParams.setKeys(keys);
		checkBatchPayoutOrderMinshengParams.setPort(minshengExt.getPort());
		checkBatchPayoutOrderMinshengParams.setVis(vis);

		return (P) checkBatchPayoutOrderMinshengParams;
	}

	@Override
	public <C extends Content> QueryBatchPayoutOrderCheckYYContent transformBatchPayoutOrderCheckContent(C rsp) throws Exception {
		CheckBatchPayoutOrderMinshengContent rspContent = (CheckBatchPayoutOrderMinshengContent) rsp;

		QueryBatchPayoutOrderCheckYYContent batchPayoutOrderCheckYYContent = new QueryBatchPayoutOrderCheckYYContent();
		if ("1".equals(rspContent.getBatchStat())) {
			double amount = rspContent.getAmount();
			batchPayoutOrderCheckYYContent.setAmount(Long.valueOf(NumberUtil.yuan2fen(amount)).intValue());
			batchPayoutOrderCheckYYContent.setCount(rspContent.getCount());

			double successAmount = rspContent.getAmount();
			batchPayoutOrderCheckYYContent.setSuccessAmount(Long.valueOf(NumberUtil.yuan2fen(successAmount)).intValue());
			batchPayoutOrderCheckYYContent.setSuccessCount(rspContent.getSuccessCount());
			double failAmount = rspContent.getFailAmount();
			batchPayoutOrderCheckYYContent.setFailAmount(Long.valueOf(NumberUtil.yuan2fen(failAmount)).intValue());
			batchPayoutOrderCheckYYContent.setFailCount(rspContent.getFailCount());

			List<MinshengBatchPayVo> volist = rspContent.getLists();
			QueryBatchPayoutOrderYYContent.QueryPayoutOrder queryPayoutOrder;

			List<QueryBatchPayoutOrderYYContent.QueryPayoutOrder> list = new ArrayList<>();
			for (MinshengBatchPayVo vo : volist) {
				queryPayoutOrder = new QueryBatchPayoutOrderYYContent.QueryPayoutOrder();
				int voAmount = (int) NumberUtil.yuan2fen(vo.getAmount());
				queryPayoutOrder.setAmount(voAmount);

				String payResultStr = vo.getPayResult();
				int resultCode;
				if("1".equals(payResultStr)) {
					resultCode = PayRspCodeEnum.SUCCESS.getValue();
				} else if("2".equals(payResultStr))  {
					resultCode = PayRspCodeEnum.PAY_CODE_PAYOUT_FAIL.getValue();
				} else {
					resultCode = PayRspCodeEnum.PAY_CODE_DEALING.getValue();
				}
				queryPayoutOrder.setResultCode(resultCode);
				queryPayoutOrder.setResultMsg(vo.getRemark());
				queryPayoutOrder.setPayeeCardNo(vo.getAccount_no());
				queryPayoutOrder.setPayeeName(vo.getName());
				queryPayoutOrder.setSerialNo(vo.getSerialno());
				queryPayoutOrder.setUserId(vo.getUser_id());
				list.add(queryPayoutOrder);
			}

			batchPayoutOrderCheckYYContent.setQueryPayoutOrders(list);
			String batchNo = rspContent.getBatchNo();
			batchPayoutOrderCheckYYContent.setBatchNo(batchNo);
			batchPayoutOrderCheckYYContent.setBatchDate(rspContent.getBatchDate());

			batchPayoutOrderCheckYYContent.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
			batchPayoutOrderCheckYYContent.setResultMsg(rspContent.getMessage());

			logger.info("民生代付日终文件对账结果:批次号{}接收交易成功，代付总金额：{}，总笔数：{}，成功金额：{}，成功笔数：{}，失败金额：{}，失败笔数:{}", batchNo, amount, rspContent.getCount(),
					successAmount, rspContent.getSuccessCount(), failAmount, rspContent.getFailCount());
		} else if ("0".equals(rspContent.getBatchStat())) {
			logger.error("民生代付对账，批次号{}未找到", rspContent.getBatchNo());
			batchPayoutOrderCheckYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_PAYOUT_BATCH_NO_NOT_FOUND.getValue());
			batchPayoutOrderCheckYYContent.setResultMsg(rspContent.getMessage());
			batchPayoutOrderCheckYYContent.setBatchNo(rspContent.getBatchNo());
			batchPayoutOrderCheckYYContent.setBatchDate(rspContent.getBatchDate());
		} else if ("3".equals(rspContent.getBatchStat())) {
			logger.error("民生代付对账，批次号{}正在处理中,稍后查询", rspContent.getBatchNo());
			batchPayoutOrderCheckYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_DEALING.getValue());
			batchPayoutOrderCheckYYContent.setResultMsg(rspContent.getMessage());
			batchPayoutOrderCheckYYContent.setBatchNo(rspContent.getBatchNo());
			batchPayoutOrderCheckYYContent.setBatchDate(rspContent.getBatchDate());
		} else {
			logger.error("民生代付对账，批次号{}返回未知状态", rspContent.getBatchNo());
			batchPayoutOrderCheckYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_UNKNOWN.getValue());
			batchPayoutOrderCheckYYContent.setResultMsg(rspContent.getMessage());
			batchPayoutOrderCheckYYContent.setBatchNo(rspContent.getBatchNo());
			batchPayoutOrderCheckYYContent.setBatchDate(rspContent.getBatchDate());
		}

		return batchPayoutOrderCheckYYContent;
	}

	@Override
	public <P extends Params> P transformBatchPayoutOrderParams(PayoutBatchOrderYYParams req) throws Exception {
		PayoutOrderMinshengParams payoutOrderMinshengParams = new PayoutOrderMinshengParams();

		String merchantCode = req.getMerchantCode();

		MinshengExt minshengExt = getMerchantInfo(merchantCode);
		payoutOrderMinshengParams.setHost(minshengExt.getHost());
		payoutOrderMinshengParams.setPort(minshengExt.getPort());
		String algorithm = minshengExt.getAlgorithm();
		payoutOrderMinshengParams.setAlgorithm(minshengExt.getAlgorithm());
		String keys = minshengExt.getKeys();
		payoutOrderMinshengParams.setKeys(keys);
		String vis = minshengExt.getVis();
		payoutOrderMinshengParams.setVis(vis);

		// 付款备注
		String remark = minshengExt.getRemark();

		String commpName = minshengExt.getCommpName();
		String date = req.getBatchDate();
		String batchNo = req.getBatchNo();
		String bindAcct = minshengExt.getBindAcct();
		String bindAcctName = minshengExt.getBindAcctName();

		String dateTime = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
		String commpCode = minshengExt.getCommpCode();

		byte[] keyBytes = MinshengUtil.hex2bin(keys);

		// 批量文件名
		String sourceName = commpCode + "_" + date + "_" + batchNo + ".req";
		String sourcePath = minshengExt.getSourcePath();

		List<PayoutOrderYY> list = req.getDataList();

		// 先生成批量代付文件
		Map<String, String> params = MinshengUtil.genFile(commpCode, date, Integer.valueOf(batchNo), sourceName, commpName, sourcePath, list, remark);
		String dataFile = params.get("dataFile");
		String totAmount = params.get("totAmount");
		String totCount = params.get("totCount");

		// 压缩文件
		String fName = MinshengUtil.gzipFile(dataFile);
		fName = MinshengUtil.encryptFile(fName, keys, vis, algorithm);
		int fileLength = (int) new File(fName).length();
		String fileMD5 = MinshengUtil.getFileMD5(dataFile, keyBytes, null);
		payoutOrderMinshengParams.setFile(fName);

		// 构造报文体
		String body = String.format("%s|%s|%s|%s|%s|%s|%s|%s|", commpName, date, batchNo, bindAcct, bindAcctName, totCount, totAmount, fileMD5);
		payoutOrderMinshengParams.setBody(body);
		byte[] bodyBytes = body.getBytes("UTF-8");

		byte[] toMD5 = new byte[38 + bodyBytes.length];

		System.arraycopy(keyBytes, 0, toMD5, 0, 24);
		System.arraycopy(dateTime.getBytes(), 0, toMD5, 24, 14);
		System.arraycopy(keyBytes, 0, toMD5, 38, keyBytes.length);

		String bodyMD5 = MinshengUtil.getMD5(toMD5);
		logger.info("bodyMD5==" + bodyMD5);

		// 构造报文头
		bodyBytes = MinshengUtil.encrypt(bodyBytes, keys, vis, algorithm);
		String header = String.format("%08d%-12s101110%06d%-14s%-16s%32s", bodyBytes.length + fileLength, "PA001B101", bodyBytes.length, dateTime,
				commpCode, bodyMD5);
		payoutOrderMinshengParams.setHeader(header);

		return (P) payoutOrderMinshengParams;
	}

	@Override
	public <C extends Content> PayoutBatchOrderYYContent transformBatchPayoutOrderContent(C rsp) throws Exception {
		PayoutOrderMinshengContent payoutOrderMinshengContent = (PayoutOrderMinshengContent) rsp;

		PayoutBatchOrderYYContent payoutBatchOrderYYContent = new PayoutBatchOrderYYContent();
		if ("1".equals(payoutOrderMinshengContent.getBatchStat())) {

			double amount = payoutOrderMinshengContent.getAmount();
			payoutBatchOrderYYContent.setAmount(Long.valueOf(NumberUtil.yuan2fen(amount)).intValue());

			payoutBatchOrderYYContent.setBatchDate(payoutOrderMinshengContent.getBatchDate());
			payoutBatchOrderYYContent.setBatchNo(payoutOrderMinshengContent.getBatchNo() + "");
			payoutBatchOrderYYContent.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
			payoutBatchOrderYYContent.setResultMsg(payoutOrderMinshengContent.getMessage());
			payoutBatchOrderYYContent.setBatchState(payoutOrderMinshengContent.getBatchStat());
		} else {
			payoutBatchOrderYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_PAYOUT_FAIL.getValue());
			payoutBatchOrderYYContent.setResultMsg(payoutOrderMinshengContent.getMessage());
			payoutBatchOrderYYContent.setBatchNo(payoutOrderMinshengContent.getBatchNo() + "");
		}

		return payoutBatchOrderYYContent;
	}

	@Override
	public <P extends Params> P transformPayOrdeParams(PayOrderYYParams req) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> PayOrderYYContent transformPayOrdeContent(C rsp) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformPayoutOrderParams(PayoutOrderYYParams rsp) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> PayoutOrderYYContent transformPayoutOrderContent(C rsp) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformQueryBatchPayoutOrderParams(QueryBatchPayoutOrderYYParams rsp) throws Exception {
		QueryBatchPayoutOrderMinshengParams queryBatchPayoutOrderMinshengParams = new QueryBatchPayoutOrderMinshengParams();

		String merchantCode = rsp.getMerchantCode();
		MinshengExt minshengExt = getMerchantInfo(merchantCode);

		String date = rsp.getBatchDate();
		// 当天第几个批次
		int batchNo = Integer.valueOf(rsp.getBatchNo());

		String keys = minshengExt.getKeys();
		byte[] keyBytes = MinshengUtil.hex2bin(keys);

		String dateTime = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
		String commpName = minshengExt.getCommpName();
		String bindAcct = minshengExt.getBindAcct();
		String bindAcctName = minshengExt.getBindAcctName();

		// 构造报文体
		String body = String.format("%s|%s|%s|%s|%s|", commpName, date, batchNo, bindAcct, bindAcctName);
		byte[] bodyBytes = body.getBytes("UTF-8");
		byte[] toMD5 = new byte[38 + bodyBytes.length];
		System.arraycopy(keyBytes, 0, toMD5, 0, 24);
		System.arraycopy(dateTime.getBytes(), 0, toMD5, 24, 14);
		System.arraycopy(bodyBytes, 0, toMD5, 38, bodyBytes.length);

		String vis = minshengExt.getVis();
		String algorithm = minshengExt.getAlgorithm();

		String bodyMD5 = MinshengUtil.getMD5(toMD5);
		bodyBytes = MinshengUtil.encrypt(bodyBytes, keys, vis, algorithm);

		String commpCode = minshengExt.getCommpCode();

		String header = String.format("%08d%-12s100010%06d%-14s%-16s%32s", bodyBytes.length, "PA001B302", bodyBytes.length, dateTime, commpCode,
				bodyMD5);

		queryBatchPayoutOrderMinshengParams.setHost(minshengExt.getHost());
		queryBatchPayoutOrderMinshengParams.setAlgorithm(algorithm);
		queryBatchPayoutOrderMinshengParams.setBody(body);
		queryBatchPayoutOrderMinshengParams.setHeader(header);
		queryBatchPayoutOrderMinshengParams.setKeys(keys);
		queryBatchPayoutOrderMinshengParams.setPort(minshengExt.getPort());
		queryBatchPayoutOrderMinshengParams.setVis(vis);

		return (P) queryBatchPayoutOrderMinshengParams;
	}

	@Override
	public <C extends Content> QueryBatchPayoutOrderYYContent transformQueryBatchPayoutOrderContent(C rsp) throws Exception {
		QueryBatchPayoutOrderMinshengContent rspContent = (QueryBatchPayoutOrderMinshengContent) rsp;

		QueryBatchPayoutOrderYYContent queryBatchPayoutOrderYYContent = new QueryBatchPayoutOrderYYContent();
		if ("1".equals(rspContent.getBatchStat())) {

			double amount = rspContent.getAmount();
			queryBatchPayoutOrderYYContent.setAmount(Long.valueOf(NumberUtil.yuan2fen(amount)).intValue());
			queryBatchPayoutOrderYYContent.setCount(rspContent.getCount());

			double successAmount = rspContent.getAmount();
			queryBatchPayoutOrderYYContent.setSuccessAmount(Long.valueOf(NumberUtil.yuan2fen(successAmount)).intValue());
			queryBatchPayoutOrderYYContent.setSuccessCount(rspContent.getSuccessCount());
			double failAmount = rspContent.getFailAmount();
			queryBatchPayoutOrderYYContent.setFailAmount(Long.valueOf(NumberUtil.yuan2fen(failAmount)).intValue());
			queryBatchPayoutOrderYYContent.setFailCount(rspContent.getFailCount());
			double unknownAmount = rspContent.getUnknownAmount();
			queryBatchPayoutOrderYYContent.setUnknownAmount(Long.valueOf(NumberUtil.yuan2fen(unknownAmount)).intValue());
			queryBatchPayoutOrderYYContent.setUnknownCount(rspContent.getUnknownCount());

			List<MinshengBatchPayVo> voList = rspContent.getLists();
			List<QueryBatchPayoutOrderYYContent.QueryPayoutOrder> list = new ArrayList<>();
			QueryBatchPayoutOrderYYContent.QueryPayoutOrder queryPayoutOrder;
			for (MinshengBatchPayVo vo : voList) {
				queryPayoutOrder = new QueryBatchPayoutOrderYYContent.QueryPayoutOrder();
				int voAmount = (int) NumberUtil.yuan2fen(vo.getAmount());
				queryPayoutOrder.setAmount(voAmount);

				String payResultStr = vo.getPayResult();
				int resultCode;
				if("1".equals(payResultStr)) {
					resultCode = PayRspCodeEnum.SUCCESS.getValue();
				} else if("2".equals(payResultStr))  {
					resultCode = PayRspCodeEnum.PAY_CODE_PAYOUT_FAIL.getValue();
				} else {
					resultCode = PayRspCodeEnum.PAY_CODE_DEALING.getValue();
				}
				queryPayoutOrder.setResultCode(resultCode);
				queryPayoutOrder.setResultMsg(vo.getRemark());
				queryPayoutOrder.setPayeeCardNo(vo.getAccount_no());
				queryPayoutOrder.setPayeeName(vo.getName());
				queryPayoutOrder.setSerialNo(vo.getSerialno());
				queryPayoutOrder.setUserId(vo.getUser_id());
				list.add(queryPayoutOrder);
			}

			queryBatchPayoutOrderYYContent.setQueryPayoutOrders(list);
			String batchNo = rspContent.getBatchNo();
			queryBatchPayoutOrderYYContent.setBatchNo(batchNo);
			queryBatchPayoutOrderYYContent.setBatchDate(rspContent.getBatchDate());

			queryBatchPayoutOrderYYContent.setResultCode(PayRspCodeEnum.SUCCESS.getValue());
			queryBatchPayoutOrderYYContent.setResultMsg(rspContent.getMessage());

			logger.info("民生代付查询结果:批次号{}接收交易成功，代付总金额：{}，总笔数：{}，成功金额：{}，成功笔数：{}，失败金额：{}，失败笔数:{}", batchNo, amount, rspContent.getCount(), successAmount,
					rspContent.getSuccessCount(), failAmount, rspContent.getFailCount());
		} else if ("0".equals(rspContent.getBatchStat()) || "2".equals(rspContent.getBatchStat())) {
			logger.error("民生代付查询，批次号{}未找到或接收失败,请确认后重发", rspContent.getBatchNo());
			queryBatchPayoutOrderYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_PAYOUT_BATCH_NO_NOT_FOUND.getValue());
			queryBatchPayoutOrderYYContent.setResultMsg(rspContent.getMessage());
			queryBatchPayoutOrderYYContent.setBatchNo(rspContent.getBatchNo());
			queryBatchPayoutOrderYYContent.setBatchDate(rspContent.getBatchDate());
		} else if ("3".equals(rspContent.getBatchStat())) {
			logger.error("民生代付查询，批次号{}正在处理中,稍后查询", rspContent.getBatchNo());
			queryBatchPayoutOrderYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_DEALING.getValue());
			queryBatchPayoutOrderYYContent.setResultMsg(rspContent.getMessage());
			queryBatchPayoutOrderYYContent.setBatchNo(rspContent.getBatchNo());
			queryBatchPayoutOrderYYContent.setBatchDate(rspContent.getBatchDate());
		} else {
			logger.error("民生代付查询，批次号{}返回未知状态", rspContent.getBatchNo());
			queryBatchPayoutOrderYYContent.setResultCode(PayRspCodeEnum.PAY_CODE_UNKNOWN.getValue());
			queryBatchPayoutOrderYYContent.setResultMsg(rspContent.getMessage());
			queryBatchPayoutOrderYYContent.setBatchNo(rspContent.getBatchNo());
			queryBatchPayoutOrderYYContent.setBatchDate(rspContent.getBatchDate());
		}

		return queryBatchPayoutOrderYYContent;
	}

	@Override
	public <P extends Params> P transformSendAuthenticationVerifyCodeParams(SendAuthenticationVerifyCodeYYParams rsp) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> SendAuthenticationVerifyCodeYYContent transformSendAuthenticationVerifyCodeContent(C req) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformSendVerifyCodeParams(SendVerifyCodeYYParams rsp) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> SendVerifyCodeYYContent transformSendVerifyCodeContent(C req) throws Exception {
		return null;
	}

	@Override
	public <P> P transformQueryCardBinParams(QueryCardBinParams rsp) {
		return null;
	}

	@Override
	public <C> QueryCardBinContent transformQueryCardBinContent(C req) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformQueryPayOutOrderParams(QueryPayoutOrderYYParams queryPayOutOrderYYParams) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> QueryPayoutOrderYYContent transformQueryPayOutOrderContent(C rsp) throws Exception {
		return null;
	}

	@Override
	public <P extends Params> P transformWithoutVerifyParams(WithoutVerifyYYParams withoutVerifyYYParams) throws Exception {
		return null;
	}

	@Override
	public <C extends Content> WithoutVerifyYYContent transformWithoutVerifyContent(C req) throws Exception {
		return null;
	}

	private MinshengExt getMerchantInfo(String merchantCode) throws Exception {
		MerchantPaymentPO merchant = merchantPaymentService.queryByThirdMerchantCode(merchantCode, PaymentEnum.MIN_SHENG.getValue(),
				PayTypeEnum.PAY_OUT.getValue(), PayModeEnum.AUTH_PAY.getValue());
		MinshengExt minshengExt = null;
		if (merchant == null) {
			logger.error("【minsheng】【pay】查询支付通过信息失败,商户信息为空,merchantCode:{}", merchantCode);
			throw new YYPayException(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue(), "查询支付通过信息失败,商户信息为空.");
		}
		if (StringUtils.isNotBlank(merchant.getExt())) {
			minshengExt = JacksonUtil.nonullMapper.fromJson(merchant.getExt(), MinshengExt.class);
		} else {
			logger.error("【minsheng】【pay】支付商户扩展信息为空,merchantCode:{}", merchantCode);
			throw new YYPayException(PayRspCodeEnum.PAY_CODE_PAY_FAIL.getValue(), "支付商户扩展信息为空");
		}
		logger.info("【minsheng】【pay】查询支付通过信息成功,merchant:{}", JacksonUtil.nonullMapper.toJson(merchant));
		return minshengExt;
	}
}
